Skip to content

Conversation

d10r
Copy link
Collaborator

@d10r d10r commented Aug 1, 2025

What & Why

see #2016

How

Imports and notes about what changed:

utils/introspection/IERC1820Registry.sol
  path changed to interfaces/

utils/introspection/ERC1820Implementer
  was removed. Used only in ERC777SenderRecipientMock.t.sol, so I put a copy there.

utils/math/SafeMath.sol
  nomore needed in Solidity 0.8, its functions can be replaced by operators

utils/math/SafeCast.sol

utils/Address.sol (SuperToken.sol)
  isContract() was removed, thus it was replaced by its previous implementation `account.code.length > 0 ?`
  The OZ5 library added a custom error, which caused the ABI to not be empty anymore, which caused typechain to add it, which caused a conflict with the alias in `mappedSubgraphTypes.ts`. Thus added a workaround in `build-types.sh` which removes the entries generated for the Address library.

utils/cryptography/ECDSA.sol

access/IAccessControl.sol

access/AccessControlEnumerable.sol
  path changed to access/extensions

access/AccessControl.sol
  `_setupRole()` was removed. Can be trivially replaced by `_grantRole()`

access/Ownable.sol
  constructor now requires an argument, initial owner needs to be explicitly set (was implicitly set to `_msgSender` before)

token/ERC20/extensions/IERC20Metadata.sol

token/ERC20/extensions/IERC20Permit.sol

token/ERC721/extensions/IERC721Metadata.sol

token/ERC777/IERC777.sol
  path changed to interfaces

token/ERC777/IERC777Recipient.sol
    path changed to interfaces

token/ERC777/IERC777Sender.sol
    path changed to interfaces

token/ERC20/ERC20.sol
  note: SuperToken does NOT inherit this, but did replicate some of the functionality, incl. revert strings. Remaining ones could be replaced by custom errors as specified in [EIP-6093](https://eips.ethereum.org/EIPS/eip-6093), as done in the OZ5 impl.

token/ERC20/utils/SafeERC20.sol (library)
  `safeApprove` has been removed (was already deprecated in v4) because there's nothing safe about it. Was used in `SuperUpgrader`, now replaced with `forceApprove` (which is specifically about ERC20 contracts which requires approval to be set to 0 before it can be set to a new value).

proxy/Proxy.sol
  receive() was removed. It was thus explicitly added to `UUPSProxy` and `FullUpgradableSuperTokenProxy` in order to keep their functionality as is.

proxy/utils/Initializable.sol
  STORAGE LAYOUT CHANGED!
  This is used in `UUPSProxiable` and `BeaconProxiable`. We need to retain the storage layout of those, thus we keep using the v4 version.

proxy/beacon/UpgradeableBeacon.sol

proxy/beacon/BeaconProxy.sol
  v5 added an immutable which stores the beacon address - additionally to storing it in the eip-1967-defined storage slot.
  This is a clever optimization allowing cheaper lookup at runtime. It's safe because the storage layout isn't affected and the beacon address is immutable thus can't get out of sync with the pointer saved in storage.

interfaces/IERC5267.sol

openzeppelin-contracts is now a git submodule (foundry style) instead of an npm package.
In order to stay compatible with hardhat (used by legacy tests) and truffle (used by ops scripts), an npm postinstall script places a symlink to that submodule in node_modules. This was found to be the only solution which doesn't cause significant issues with either hardhat or truffle (see dedicated comment).

The openzeppelin imports in the ethereum-contracts package are now qualified by the major version, that is @openzeppelin-v5/.... This allows contracts using SF contracts as a dependency to use the default namespace @openzeppelin with the OZ version they prefer. The OZ package is now declared a peerDependency.
Hardhat projects need to set up a remapping task in their config file, see CHANGELOG.

@d10r d10r marked this pull request as ready for review August 7, 2025 19:28
@d10r d10r requested a review from kasparkallas as a code owner August 7, 2025 19:28
@d10r
Copy link
Collaborator Author

d10r commented Aug 7, 2025

We could change EVM version to cancun, all SF networks now support it (see hellwolf/eip-canaries#1).
However ganache doesn't support it, so I reverted to shanghai.

@hellwolf
Copy link
Contributor

hellwolf commented Aug 21, 2025

@d10r, please cherry-pick #2099


console.log("Revert with overflow.");
vm.expectRevert("SafeCast: value doesn't fit in 96 bits");
vm.expectRevert(); // SafeCastOverflowedIntDowncast
Copy link
Contributor

@hellwolf hellwolf Aug 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no reference to it?


console.log("Revert with overflow.");
vm.expectRevert("SafeCast: value doesn't fit in 96 bits");
vm.expectRevert(); // SafeCastOverflowedIntDowncast
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

newCtx = ctx;

if (pool.superToken().isPool(this, memberAddr)) {
if (memberAddr == address(0) || pool.superToken().isPool(this, memberAddr)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sneaky.

error NO_PROXY_LOOP(); // 0z66750bca

constructor(address implementation_) UpgradeableBeacon(implementation_) {}
constructor(address implementation_) UpgradeableBeacon(implementation_, _msgSender()) {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

  • Context._msgSender
  • Ownable is Context

() => superfluid.getSimpleACL(),
"SIMPLE_ACL"
);
// SimpleACL has now been deployed on all networks.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. What about deploying to a new network, does the bootstrap logic still exist?

vm.stopPrank();

// cannot connect the zero address
vm.startPrank(alice);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay

spender,
_allowances[holder][spender].sub(amount, "SuperToken: transfer amount exceeds allowance"));
require(amount <= _allowances[holder][spender], "SuperToken: transfer amount exceeds allowance");
// TODO: this triggers an `Approval` event, which shouldn't happen for transfers.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't recall when did this creep in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a draft to https://github.com/orgs/superfluid-org/projects/1/views/1 for later to address.

// Go to https://hardhat.org/config/ to learn more

// Remapping for OpenZeppelin contracts
subtask(TASK_COMPILE_GET_REMAPPINGS).setAction(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*
* CAUTION: This file is deprecated as of v4.9 and will be removed in the next major release.
*/
contract ERC1820Implementer is IERC1820Implementer {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider to move it under contracts/utils/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ETHEREUM-CONTRACTS] Upgrade to OpenZeppelin 5 and Rework Its Dependency Management (Breaking Chnage)

4 participants